﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ControleFinanceiro
{
    public partial class WebForm2 : System.Web.UI.Page
    {
       int contador = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        public WebForm2()
        {
         this.Load += new EventHandler(BuscaData);
         this.PreRender += new EventHandler(SalvaData);

        }
    
            void BuscaData(object sender, EventArgs e)
            {
                    if (IsPostBack){Calendar1.SelectedDate = (DateTime)ViewState["DataSelecionada"];
                    contador = Convert.ToInt16(ViewState["Contador"]);
                    }
            }

            void SalvaData(object sender, EventArgs e)
            {
                    ViewState["DataSelecionada"] = Calendar1.SelectedDate;
                    ViewState["Contador"] = contador;
            }

        

        protected void Button1_Click(object sender, EventArgs e)
        {
            contador++;
        }

        protected void btnVariavel_Click(object sender, EventArgs e)
        
        {
            txtVariavel.Text = Convert.ToString(contador);
        }
        
       
    }
}